/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frame.BanHang;

import dao.ChiTietPhieuNhapKhoDAO;
import dao.CuaHangDAO;
import dao.DanhMucDAO;
import dao.DonViDAO;
import dao.PhieuNhapKhoDAO;
import dao.SanPhamDAO;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import pojo.Chitietphieunhapkho;
import pojo.Cuahang;
import pojo.Danhmuc;
import pojo.Donvi;
import pojo.Nhanvien;
import pojo.Phieunhapkho;
import pojo.Sanpham;

/**
 *
 * @author Quan
 */
public class PhieuNhapKho extends myclass.MyAdminFrame {

    private DefaultTableModel tablemode;

    /**
     * Creates new form PhieuNhapKho2
     */
    public PhieuNhapKho(Nhanvien nv) {
        super(nv);
        initComponents();
        LoadCuaHang();
        LoadDanhMuc();
        LoadDonVi();
        this.jtf_nguoilap.setText(this.nv.getHoten());
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
        Date date = new Date();
        this.jtf_ngaylap.setText(dateFormat.format(date));

        tablemode = new DefaultTableModel();
        tablemode.addColumn("STT");
        tablemode.addColumn("Sản Phẩm");
        tablemode.addColumn("Đơn Vị");
        tablemode.addColumn("Đơn Giá");
        tablemode.addColumn("Số Lượng");
        tablemode.addColumn("Thành Tiền");
        jTable1.setModel(tablemode);
    }

    private void LoadCuaHang() {
        CuaHangDAO cuaHangDAO = new CuaHangDAO();
        List<Cuahang> ls = null;
        try {
            ls = cuaHangDAO.LayDanhSach();
        } catch (Exception ex) {
            Logger.getLogger(PhieuNhapKho.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }
        jccb_cuahang.addItem(null);
        for (int i = 0; i < ls.size(); i++) {
            Cuahang cuahang = ls.get(i);
            jccb_cuahang.addItem(cuahang);
        }
    }

    private void LoadDanhMuc() {
        DanhMucDAO danhMucDAO = new DanhMucDAO();
        List<Danhmuc> ls = null;
        try {
            ls = danhMucDAO.LayDanhSach();
        } catch (Exception ex) {
            Logger.getLogger(PhieuNhapKho.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }
        jcbb_danhmuc.addItem(null);
        for (int i = 0; i < ls.size(); i++) {
            Danhmuc danhmuc = ls.get(i);
            jcbb_danhmuc.addItem(danhmuc);
        }
    }

    private void LoadSanPham(Danhmuc danhmuc) {
        jcbb_sanpham.removeAllItems();
        SanPhamDAO sanPhamDAO = new SanPhamDAO();
        List<Sanpham> ls = null;
        try {
            ls = sanPhamDAO.LayDanhSach(danhmuc);
        } catch (Exception ex) {
            Logger.getLogger(PhieuNhapKho.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }
        jcbb_sanpham.addItem(null);
        for (int i = 0; i < ls.size(); i++) {
            Sanpham sanpham = ls.get(i);
            jcbb_sanpham.addItem(sanpham);
        }
    }

    private void LoadDonVi() {
        DonViDAO donViDAO = new DonViDAO();
        List<Donvi> ls = null;
        try {
            ls = donViDAO.LayDanhSach();
        } catch (Exception ex) {
            Logger.getLogger(PhieuNhapKho.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }
        jcbb_donvi.addItem(null);
        for (int i = 0; i < ls.size(); i++) {
            Donvi donvi = ls.get(i);
            jcbb_donvi.addItem(donvi);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jtf_nguoilap = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jtf_ngaylap = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jccb_cuahang = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jtf_ghichu = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton3 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jcbb_danhmuc = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jcbb_sanpham = new javax.swing.JComboBox();
        jtf_dongia = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jtf_soluong = new javax.swing.JTextField();
        jButton4 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jcbb_donvi = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin phiếu nhập kho"));

        jtf_nguoilap.setEditable(false);

        jLabel1.setText("Người lập phiếu");

        jLabel2.setText("Ngày lập phiếu");

        jLabel3.setText("Của hàng");

        jLabel4.setText("Ghi chú");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtf_nguoilap)
                    .addComponent(jtf_ngaylap))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jccb_cuahang, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jtf_ghichu))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtf_nguoilap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jccb_cuahang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtf_ngaylap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jtf_ghichu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Chi tiết phiếu nhập kho"));

        jTable1.setAutoCreateRowSorter(true);
        jScrollPane1.setViewportView(jTable1);

        jButton3.setText("Xóa");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel7.setText("Đơn giá");

        jLabel8.setText("Sản phẩm");

        jcbb_danhmuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbb_danhmucActionPerformed(evt);
            }
        });

        jLabel9.setText("Danh mục");

        jLabel10.setText("Số lượng");

        jButton4.setText("Thêm");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel5.setText("Đơn vị");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel7)
                            .addComponent(jLabel5))
                        .addGap(47, 47, 47)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtf_dongia, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
                            .addComponent(jcbb_danhmuc, 0, 237, Short.MAX_VALUE)
                            .addComponent(jcbb_donvi, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel10))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtf_soluong)
                                    .addComponent(jcbb_sanpham, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addGap(204, 204, 204)
                                .addComponent(jButton4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton3)))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel9)
                        .addComponent(jcbb_danhmuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jcbb_sanpham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jtf_dongia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jtf_soluong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton3)
                        .addComponent(jButton4))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel5)
                        .addComponent(jcbb_donvi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jButton1.setText("Đóng");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Lưu");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jcbb_danhmucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbb_danhmucActionPerformed
        // TODO add your handling code here:
        Object ob = jcbb_danhmuc.getSelectedItem();
        if (ob != null) {
            LoadSanPham((Danhmuc) ob);
        } else {
            jcbb_sanpham.removeAllItems();
        }
    }//GEN-LAST:event_jcbb_danhmucActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        Chitietphieunhapkho chitietphieunhapkho = new Chitietphieunhapkho();
        Object sanpham = jcbb_sanpham.getSelectedItem();
        if (sanpham != nv) {
            chitietphieunhapkho.setSanpham((Sanpham) sanpham);
        }
        try {
            chitietphieunhapkho.setDongianhap(Double.valueOf(jtf_dongia.getText()));
            chitietphieunhapkho.setSoluong(Double.valueOf(jtf_soluong.getText()));
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(rootPane, "Lỗi định dạng", "Thông báo:", JOptionPane.ERROR_MESSAGE);
            return;
        } catch (Exception e) {
            return;
        }
        Object donvi = jcbb_donvi.getSelectedItem();
        if (donvi != null) {
            chitietphieunhapkho.setDonvi((Donvi) donvi);
        }
        tablemode.addRow(new Object[]{
                    tablemode.getRowCount() + 1,
                    chitietphieunhapkho,
                    donvi,
                    chitietphieunhapkho.getDongianhap(),
                    chitietphieunhapkho.getSoluong(),
                    chitietphieunhapkho.getDongianhap() * chitietphieunhapkho.getSoluong()
                });
        tablemode.fireTableDataChanged();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        int index = jTable1.getSelectedRow();
        if (index != -1) {
            tablemode.removeRow(index);
            tablemode.fireTableDataChanged();
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        Phieunhapkho phieunhapkho = new Phieunhapkho();
        Object cuahang = jccb_cuahang.getSelectedItem();
        if (cuahang != null) {
            phieunhapkho.setCuahang((Cuahang) cuahang);
        }
        phieunhapkho.setGhichu(jtf_ghichu.getText());
        phieunhapkho.setNhanvien(this.nv);
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
        try {
            phieunhapkho.setNgaylapphieu(dateFormat.parse(jtf_ngaylap.getText()));
        } catch (ParseException ex) {
            Logger.getLogger(PhieuNhapKho.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }
        double giatri = 0;
        for (int i = 0; i < tablemode.getRowCount(); i++) {
            Chitietphieunhapkho chitietphieunhapkho = (Chitietphieunhapkho) tablemode.getValueAt(i, 1);
            giatri += chitietphieunhapkho.getSoluong() * chitietphieunhapkho.getDongianhap();
        }
        phieunhapkho.setTonggiatrinhap(giatri);

        PhieuNhapKhoDAO phieuNhapKhoDAO = new PhieuNhapKhoDAO();
        ChiTietPhieuNhapKhoDAO chiTietPhieuNhapKhoDAO = new ChiTietPhieuNhapKhoDAO();
        try {
            phieuNhapKhoDAO.Them(phieunhapkho);
            for (int i = 0; i < tablemode.getRowCount(); i++) {
                Chitietphieunhapkho chitietphieunhapkho = (Chitietphieunhapkho) tablemode.getValueAt(i, 1);
                chitietphieunhapkho.setPhieunhapkho(phieunhapkho);
                chiTietPhieuNhapKhoDAO.Them(chitietphieunhapkho);
            }
        } catch (Exception ex) {
            Logger.getLogger(PhieuNhapKho.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "Thông báo", JOptionPane.ERROR_MESSAGE);
        }

    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.hide();
    }//GEN-LAST:event_jButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JComboBox jcbb_danhmuc;
    private javax.swing.JComboBox jcbb_donvi;
    private javax.swing.JComboBox jcbb_sanpham;
    private javax.swing.JComboBox jccb_cuahang;
    private javax.swing.JTextField jtf_dongia;
    private javax.swing.JTextField jtf_ghichu;
    private javax.swing.JTextField jtf_ngaylap;
    private javax.swing.JTextField jtf_nguoilap;
    private javax.swing.JTextField jtf_soluong;
    // End of variables declaration//GEN-END:variables
}
